const router = require('koa-router')()
var https = require('https')
var fs = require('fs')
var mysql = require('mysql')

// 在putty上打开数据库：mysql -u secondroot -p

var con = mysql.createConnection({
  host: "110.40.250.194",
  port: 3306,
  user: "secondroot",
  password: "20705",
  database: "mengya"
})

router.get('/users', async (ctx, next) => {
  var selectSql = 'select * from users'

  let res = await new Promise((resolve, reject) => {
    con.query(selectSql, (err, result) => {
      if (err) {
        console.log(err)
      } else {
        resolve(result)

      }
    })
  })
  console.log(res)
  ctx.body = res
  console.log('hhh')
})



module.exports = router
